import { http } from "@/utils/http";

// 查询数据字典列表
export const listType = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/dictType/pageList", { data });
};

// 新增数据字典类型
export const addType = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/dictType/save", { data });
};

// 修改数据字典类型
export const updateType = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/dictType/updateById", { data });
};

// 删除数据字典类型
export const delType = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/dictType/delByIds", { data });
};

// 启用/禁用
export const ableType = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/dictType/updateStatus", { data });
};

/******字典数据相关接口 *******/
export const dataSave = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/dictItem/save", { data });
};

export const dataUpdate = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/dictItem/update", { data });
};

export const dataDel = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/dictItem/delByIds", { data });
};

export const dataList = (data?: Record<string, any>) => {
  return http.request<any[]>("post", "/account/api/v1/dictType/queryListByTypeCode", {
    data
  });
};

export const dataImport = (data?: Record<string, any>) => {
  return http.request(
    "post",
    "/account/api/v1/dictItem/importItem",
    {
      data
    },
    {
      headers: {
        "Content-type": "multipart/form-data"
      }
    }
  );
};

export const dataEnable = (data?: Record<string, any>) => {
  return http.request("post", "/account/api/v1/dictItem/updateStatus", { data });
};
